import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'

export const citySlice = createSlice({
  name: 'city',
  initialState: {
    avator:localStorage.getItem('avator'),
    name:localStorage.getItem('name'),
    start:'北京',
    end:'广州',
    date:dayjs().format('MM-DD')
  },
  reducers: {
    changecity(state,{payload}){
        let x=state.start
        state.start=state.end
        state.end=x
    },
    excity(state,{payload}){
        state[payload.id]=payload.city
    },
    chdate(state,{payload}){
        state.date=payload.date
    }




  },
})

// Action creators are generated for each case reducer function
export const { changecity,excity,chdate } = citySlice.actions

export default citySlice.reducer